﻿<%@ Page Language="C#" AutoEventWireup="false" ContentType="text/html" ResponseEncoding="gb2312" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Error Log</title>
</head>
<body>
<form id="form1" runat="server">
	<div>
		<input type="button" value="View Error Log" onclick="javascript:window.open('elmah.axd')" />
		<asp:Button ID="btnClear" runat="server" Text="Clear Error Log" OnClientClick="javascript:return confirm('sure ?')" onclick="btnClear_Click" />
	</div>
</form>
</body>
</html>

<script runat="server">
	protected void btnClear_Click(object sender, EventArgs e) {
		string path = ((Hashtable)ConfigurationManager.GetSection("elmah/errorLog"))["logPath"].ToString();
		path = Server.MapPath(path);

		string[] files = System.IO.Directory.GetFiles(path);

		foreach (string file in files) {
			System.IO.File.Delete(file);
			Response.Write(file + "<br />");
		}
	}
</script>